﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

public class InteriorDesigner {

    public void FurnishRooms()
    {
        //Furniture
        List<GameObject> bathroomFurniture = new List<GameObject>();
        List<GameObject> livingRoomFurniture = new List<GameObject>();
        List<GameObject> kitchenFurniture = new List<GameObject>();
        List<GameObject> bedRoomFurniture = new List<GameObject>();
        List<GameObject> officeFurniture = new List<GameObject>();

        List<GameObject> furniturePrefabs =  DataStorage.Instance.GetFurniturePrefabs();

        FurniturePiece allo = furniturePrefabs[2].GetComponent<FurniturePiece>();

        bathroomFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("Toilet")));
        bathroomFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("Bathtub")));
        bathroomFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("Laundromat")));
        bathroomFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("LaundryBasket")));
        bathroomFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("Sink")));

        livingRoomFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("Table")));
        livingRoomFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("Chair")));
        livingRoomFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("Couch")));
        livingRoomFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("CouchTable")));

        bedRoomFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("Bed")));
        bedRoomFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("Closet")));

        officeFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("OfficeChair")));
        officeFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("OfficeTable")));
        officeFurniture.Add(furniturePrefabs.Find(go => go.name.Equals("Printer")));



        //Floors
        List<GameObject> bathroomFloor = new List<GameObject>();
        List<GameObject> livingRoomFloor = new List<GameObject>();//etc
        List<GameObject> bedRoomFloor = new List<GameObject>();
        List<GameObject> officeFloor = new List<GameObject>();

        List<GameObject> floorPrefabs = DataStorage.Instance.GetFloorPrefabs();

        bathroomFloor.Add(floorPrefabs.Find(go => go.name.Equals("FloorBathroom")));

        livingRoomFloor.Add(floorPrefabs.Find(go => go.name.Equals("FloorLivingroom")));

        bedRoomFloor.Add(floorPrefabs.Find(go => go.name.Equals("FloorBedroom")));

        officeFloor.Add(floorPrefabs.Find(go => go.name.Equals("FloorBedroom")));




        if (floorPrefabs.Find(go => go.name.Equals("BathroomFloor")) == null)
            Debug.Log("");




        //GameObject toilet = Resources.Load("Prefabs/Toilet", typeof(GameObject)) as GameObject;

        //bathroomFurniture.Add(toilet);

        //foreach (FurniturePiece furnitureElement in pseudoFurnitureList) //TODO: List or something for all the furniture available and remove this pseudoList plz
        //{
        //    foreach (RoomType roomTypeElement in furnitureElement.possibleRooms)
        //    {
        //        if (roomTypeElement.Equals(RoomType.Bathroom))
        //            bathroomFurniture.Add(roomTypeElement);
        //        if (roomTypeElement.Equals(RoomType.BedRoom))
        //            bathroomFurniture.Add(roomTypeElement);
        //        if (roomTypeElement.Equals(RoomType.Kitchen))
        //            bathroomFurniture.Add(roomTypeElement);
        //        if (roomTypeElement.Equals(RoomType.LivingRoom))
        //            bathroomFurniture.Add(roomTypeElement);
        //    }
        //}


        List<Room> roomList = DataStorage.Instance.GetRoomList();
        int numberOfEnumsRoomType = Enum.GetNames(typeof(RoomType)).Length;
        //foreach (Room roomElement in roomList)
        //{
        //    roomElement.Furnish(bathroomFurniture);
        //}
        roomList[1].Furnish(bathroomFurniture, bathroomFloor);
        roomList[2].Furnish(livingRoomFurniture, livingRoomFloor);
        roomList[3].Furnish(bedRoomFurniture, bedRoomFloor);
        roomList[4].Furnish(officeFurniture, officeFloor);
    }
	

}
